<?php
    if ($_POST) {
        
        include_spip('classes/alohacart');
        $cart = new AlohaCart();
        
        // Добавление продукта
        if ($_POST['act'] == 'add_product') {
        $p = array();
        $id_product = $_POST["id_product"];
        $p['id_product'] = $id_product;
        $p['article'] = $_POST["article"];
        $p['titre'] = $_POST["titre"];
        $p['price'] = $_POST["price"];
        $p['price'] = str_replace(array(' ', ','), array('','.'), $p['price']); // Удаляем пробелы, и заменяем запятые на точки
        $p['img_file'] = $_POST["img_file"];
        $p['link'] = $_POST["link"];
        $p['price_one'] = $p['price'];
        $p['quantity'] = 1;
        ///var_dump($p); exit;
        $cart->AddProduct($id_product, $p);
        // This is difference!!!
        $cart_quantity = $cart->CountProducts();
        $cart_price = $cart->CountPrice();
        
        $data = array('cart_quantity' => $cart_quantity, 'cart_price' => $cart_price);
        exit(json_encode($data)); 
        }
        
        // Очиска корзины
        if ($_POST['act'] == 'clear_cart') {            
            $cart->ClearCart();
            exit('DeleteOK');
        }
    }
?>